package com.yayo.mangement.controller.poi;

import com.google.common.collect.Lists;
import com.yayo.mangement.authentication.annotations.ExcelExport;
import com.yayo.mangement.iface.XlsxExporter;

import java.util.ArrayList;
import java.util.List;

/**
 * @desc:
 * @author: yang
 * @date: 2022/10/24
 */
@ExcelExport(code = "test")
public class TestService implements XlsxExporter<Test, TextContext> {

    /**
     * @param context 入参
     * @return
     */
    @Override
    public List<Test> export(TextContext context) {
        //组装要导出的数据集合
        List<Test> list = new ArrayList<>();
        for(int i = 0 ; i < 10; i ++){
            Test test = new Test();
            test.setColumn1(i + "Column1");
            test.setColumn2(i + "Column2");
            test.setColumn3(i + "Column3");
            test.setColumn4(i + "Column4");
            test.setColumn5(i + "Column5");
            test.setColumn6(i + "Column6");
            test.setColumn7(i + "Column7");
            test.setColumn8(i + "Column8");
            test.setList(Lists.newArrayList("23123","24123","4553453"));
            test.setList2(Lists.newArrayList("侧萨芬","阿斯顿发斯蒂芬","的发送到发斯蒂芬","qsfsdfsdf"));
            if(i == 2){
                test.setList(Lists.newArrayList("23123"));
                test.setList2(Lists.newArrayList("侧萨芬"));
            }
            if(i == 3){
                test.setList(Lists.newArrayList("23123","埃尔法士大夫"));
                test.setList2(Lists.newArrayList());
            }
            if(i == 4){
                test.setList(null);
                test.setList2(null);
            }
            test.setChildren(Lists.newArrayList(Child.builder().name("子表1").age("子表2").email("子表3").build(),
                    Child.builder().name("张三").age("12").email("34313234@1123.com").build()));
            list.add(test);
        }
        //返回导出的数据集合
        return list;
    }


}
